<?php 

class Controller_Payment extends Controller_Website {

    public function action_list() {
        $m_paymentNotice = Model::factory('paymentNotice');
        $total = $m_paymentNotice->count();
        $pager = new Pager($total, 15);
        $paymentNotice = $m_paymentNotice->select($pager->offset, $pager->size)->as_array();
        
        
        //获取用户的昵称
        $m_personInfo = Model::factory('personInfo');
        $personInfo = $m_personInfo->getAll()->as_array();
        foreach ($paymentNotice as &$item) {
            foreach ($personInfo as $item2) {
                if ($item['user_id'] == $item2['uid']) {
                    $item['nick_name'] = $item2['nick_name'];
                }
            }
            if (!isset($item['nick_name'])) {
                $item['nick_name'] = '未命名';
            }
        }
        
        
//         var_dump($order);exit;
        $this->content = View::factory('payment/list');
        $this->content->paymentNotice = $paymentNotice;
        $this->content->pager = $pager;
    }

    //充值记录列表
    public function action_recharge_list() {
        $m_paymentNotice = Model::factory('paymentNotice');
        $total = $m_paymentNotice->count(array('order_type'=>1,'is_paid'=>1));
        $pager = new Pager($total, 15);
        $paymentNotice = $m_paymentNotice->select($pager->offset, $pager->size,array('order_type'=>1,'is_paid'=>1))->as_array(); //筛选出已支付和是充值订单的记录
        //获取用户的昵称
        $m_personInfo = Model::factory('personInfo');
        $personInfo = $m_personInfo->getAll()->as_array();
        foreach ($paymentNotice as &$item) {
            foreach ($personInfo as $item2) {
                if ($item['user_id'] == $item2['uid']) {
                    $item['nick_name'] = $item2['nick_name'];
                }
            }
            if (!isset($item['nick_name'])) {
                $item['nick_name'] = '未命名';
            }
        }


//         var_dump($order);exit;
        $this->content = View::factory('payment/recharge_list');
        $this->content->paymentNotice = $paymentNotice;
        $this->content->pager = $pager;
    }


    //提现记录列表
    public function action_withdraw_list() {
        $m_paymentNotice = Model::factory('paymentNotice');
        $total = $m_paymentNotice->count(array('order_type'=>2));
        $pager = new Pager($total, 15);
        $paymentNotice = $m_paymentNotice->select($pager->offset, $pager->size,array('order_type'=>2))->as_array(); //筛选出是提现订单的记录
        //获取用户的昵称
        $m_personInfo = Model::factory('personInfo');
        $personInfo = $m_personInfo->getAll()->as_array();
        foreach ($paymentNotice as &$item) {
            foreach ($personInfo as $item2) {
                if ($item['user_id'] == $item2['uid']) {
                    $item['nick_name'] = $item2['nick_name'];
                }
            }
            if (!isset($item['nick_name'])) {
                $item['nick_name'] = '未命名';
            }
        }


//         var_dump($order);exit;
        $this->content = View::factory('payment/withdraw_list');
        $this->content->paymentNotice = $paymentNotice;
        $this->content->pager = $pager;
    }

   
}
